From: Jeroen van der Heijden Date: Fri, 6 Apr 2018 09:15:58 +0000 (+0200) Subject: Update database schema X-Git-Tag: archive/raspbian/2.0.44-1+rpi1~1^2~3^2~9^2~39 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=745e739af35ffb206b98639aae98492eaf4ac118;p=siridb-server.git Update database schema --- diff --git a/include/siri/db/db.h b/include/siri/db/db.h index f63ad467..e75a10e1 100644 --- a/include/siri/db/db.h +++ b/include/siri/db/db.h @@ -31,7 +31,7 @@ #define SIRIDB_MAX_SIZE_ERR_MSG 1024 #define SIRIDB_MAX_DBNAME_LEN 256 // 255 + NULL -#define SIRIDB_SCHEMA 2 +#define SIRIDB_SCHEMA 3 #define SIRIDB_FLAG_REINDEXING 1 #define DEF_DROP_THRESHOLD 1.0 // 100% diff --git a/src/siri/db/db.c b/src/siri/db/db.c index fa931897..6b6a99e7 100644 --- a/src/siri/db/db.c +++ b/src/siri/db/db.c @@ -368,7 +368,7 @@ static int SIRIDB_from_unpacker( } /* check schema */ - if (qp_schema.via.int64 == 1) + if (qp_schema.via.int64 == 1 || qp_schema.via.int64 == 2) { log_info( "Found an old database schema (v%d), " diff --git a/src/siri/db/shard.c b/src/siri/db/shard.c index 03fc0d77..801e3e48 100644 --- a/src/siri/db/shard.c +++ b/src/siri/db/shard.c @@ -40,7 +40,7 @@ #define SHARD_GROW_SZ 131072 /* shard schema (schemas below 20 are reserved for Python SiriDB) */ -#define SIRIDB_SHARD_SHEMA 20 +#define SIRIDB_SHARD_SHEMA 21 /* * Header schema layout @@ -208,6 +208,17 @@ int siridb_shard_load(siridb_t * siridb, uint64_t id) return -1; } + uint8_t schema = (uint8_t) header[HEADER_SCHEMA]; + if (schema > SIRIDB_SHARD_SHEMA) + { + fclose(fp); + log_critical( + "Shard file '%s' has schema '%u' which is not supported with " + "this version of SiriDB.", shard->fn, schema); + siridb_shard_decref(shard); + return -1; + } + /* set shard type, flags and max_chunk_sz */ shard->tp = (uint8_t) header[HEADER_TP]; shard->flags = (uint8_t) header[HEADER_FLAGS] | SIRIDB_SHARD_IS_LOADING;